package com.example.starseas_phone;

import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;

public class MainF2 extends Fragment implements View.OnClickListener {

    private LinearLayout mainf2_linear_Stu;
    private LinearLayout mainf2_linear_Tea;
    private LinearLayout mainf2_linear_Dept;

    private LinearLayout mainf2_stu1;
    private LinearLayout mainf2_stu2;
    private LinearLayout mainf2_stu3;

    private LinearLayout mainf2_tea1;
    private LinearLayout mainf2_tea2;
    private LinearLayout mainf2_tea3;
    private LinearLayout mainf2_tea4;
    private LinearLayout mainf2_tea5;

    private LinearLayout mainf2_dept1;
    private LinearLayout mainf2_dept2;
    private LinearLayout mainf2_dept3;
    private LinearLayout mainf2_dept4;
    private LinearLayout mainf2_dept5;
    private LinearLayout mainf2_dept6;


    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        return inflater.inflate(R.layout.mainf2,container,false);
    }

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        initid();
        if (Sto.State==1){
            mainf2_linear_Dept.setVisibility(View.GONE);
            mainf2_linear_Stu.setVisibility(View.VISIBLE);
            mainf2_linear_Tea.setVisibility(View.GONE);
        }else {
            if (Sto.teachers.getPositionId()==6){
                mainf2_linear_Dept.setVisibility(View.VISIBLE);
                mainf2_linear_Stu.setVisibility(View.GONE);
                mainf2_linear_Tea.setVisibility(View.GONE);
            }else {
                mainf2_linear_Dept.setVisibility(View.GONE);
                mainf2_linear_Stu.setVisibility(View.GONE);
                mainf2_linear_Tea.setVisibility(View.VISIBLE);
            }
        }
    }

    private void initid(){
        mainf2_linear_Stu = (LinearLayout) getActivity().findViewById(R.id.mainf2_linear_Stu);
        mainf2_linear_Tea = (LinearLayout) getActivity().findViewById(R.id.mainf2_linear_Tea);
        mainf2_linear_Dept = (LinearLayout) getActivity().findViewById(R.id.mainf2_linear_Dept);

        mainf2_stu1 = (LinearLayout)getActivity().findViewById(R.id.mainf2_stu1);
        mainf2_stu1.setOnClickListener(this);
        mainf2_stu2 = (LinearLayout)getActivity().findViewById(R.id.mainf2_stu2);
        mainf2_stu2.setOnClickListener(this);
        mainf2_stu3 = (LinearLayout)getActivity().findViewById(R.id.mainf2_stu3);
        mainf2_stu3.setOnClickListener(this);

        mainf2_tea1 = (LinearLayout) getActivity().findViewById(R.id.mainf2_tea1);
        mainf2_tea1.setOnClickListener(this);
        mainf2_tea2 = (LinearLayout) getActivity().findViewById(R.id.mainf2_tea2);
        mainf2_tea2.setOnClickListener(this);
        mainf2_tea3 = (LinearLayout) getActivity().findViewById(R.id.mainf2_tea3);
        mainf2_tea3.setOnClickListener(this);
        mainf2_tea4 = (LinearLayout) getActivity().findViewById(R.id.mainf2_tea4);
        mainf2_tea4.setOnClickListener(this);
        mainf2_tea5 = (LinearLayout) getActivity().findViewById(R.id.mainf2_tea5);
        mainf2_tea5.setOnClickListener(this);

        mainf2_dept1 = (LinearLayout) getActivity().findViewById(R.id.mainf2_dept1);
        mainf2_dept1.setOnClickListener(this);
        mainf2_dept2 = (LinearLayout) getActivity().findViewById(R.id.mainf2_dept2);
        mainf2_dept2.setOnClickListener(this);
        mainf2_dept3 = (LinearLayout) getActivity().findViewById(R.id.mainf2_dept3);
        mainf2_dept3.setOnClickListener(this);
        mainf2_dept4 = (LinearLayout) getActivity().findViewById(R.id.mainf2_dept4);
        mainf2_dept4.setOnClickListener(this);
        mainf2_dept5 = (LinearLayout) getActivity().findViewById(R.id.mainf2_dept5);
        mainf2_dept5.setOnClickListener(this);
        mainf2_dept6 = (LinearLayout) getActivity().findViewById(R.id.mainf2_dept6);
        mainf2_dept6.setOnClickListener(this);
    }

    @Override
    public void onClick(View view) {
        switch (view.getId()){
            case R.id.mainf2_stu1:
                Intent intent11 = new Intent(getActivity(),ResultsQueryActivity.class);
                startActivity(intent11);
                break;
            case R.id.mainf2_stu2:
                Intent intent12 = new Intent(getActivity(),Applyrecord_StuActivity.class);
                startActivity(intent12);
                break;
            case R.id.mainf2_stu3:
                Intent intent13 = new Intent(getActivity(),AddevaluationActivity.class);
                startActivity(intent13);
                break;
            case R.id.mainf2_tea1:
                Intent intent26 = new Intent(getActivity(),AddStuListActivity.class);
                startActivity(intent26);
                break;
            case R.id.mainf2_tea2:
                Intent intent22 = new Intent(getActivity(),Apply_ScoreManageActivity.class);
                startActivity(intent22);
                break;
            case R.id.mainf2_tea3:
                Intent intent23 = new Intent(getActivity(),Applyrecord_TeaActivity.class);
                startActivity(intent23);
                break;
            case R.id.mainf2_tea4:
                Intent intent24 = new Intent(getActivity(),Tea_AllStudentsActivity.class);
                startActivity(intent24);
                break;
            case R.id.mainf2_tea5:
                Intent intent25 = new Intent(getActivity(),TeaApplyActivity.class);
                startActivity(intent25);
                break;
            case R.id.mainf2_dept1:
                Intent intent31 = new Intent(getActivity(),CollegemanageActivity.class);
                startActivity(intent31);
                break;
            case R.id.mainf2_dept2:
                Intent intent32 = new Intent(getActivity(),ClassmanageActivity.class);
                startActivity(intent32);
                break;
            case R.id.mainf2_dept3:
                Intent intent33 = new Intent(getActivity(),ProfessionalManageActivity.class);
                startActivity(intent33);
                break;
            case R.id.mainf2_dept4:
                Intent intent34 = new Intent(getActivity(),WorkerManageActivity.class);
                startActivity(intent34);
                break;
            case R.id.mainf2_dept5:
                Intent intent35 = new Intent(getActivity(),DeptApplyActivity.class);
                startActivity(intent35);
                break;
            case R.id.mainf2_dept6:
                Intent intent36 = new Intent(getActivity(),Stu_evaluationActivity.class);
                intent36.putExtra("id","6");
                startActivity(intent36);
                break;
        }
    }

}